$(function () {
    var _html = window.location.href.split("http:")[1],
        url,
        urls = [],
        pro_url,
        pro__menuurl,
        pro_urls = [];
    $(".kj-mainnav > li").each(function () {
        url = $(this).children("a").attr('href');
        urls.push(url);
    });
    for (var key in urls) {
        if (urls[key] == _html) {
            $(".kj-mainnav > li").removeClass("active");
            $(".kj-mainnav > li").eq(key).addClass("active");
        }
    }
    var nowIndex = 0;
    $(".next").click(function () {
        if (nowIndex < ($(".bannerSlide > .item").length - 1)) {
            nowIndex++;
        } else {
            nowIndex = 0;
        }
        bannerAnimate();
    });
    $(".prev").click(function () {
        if (nowIndex > 0) {
            nowIndex--;
        } else {
            nowIndex = ($(".bannerSlide > .item").length - 1)
        }
        bannerAnimate();
    });
    $(".middle_points span").click(function () {
        $(".middle_points span").removeClass("now");
        $(this).addClass("now");
        nowIndex = $(this).index();
        bannerAnimate();
    });
    var setTime = setInterval(function () {
        $(".next").eq(nowIndex).click();
    }, 3000);
    $(".kj_banner").mouseover(function () {
        clearInterval(setTime);
    });
    $(".kj_banner").mouseout(function () {
        setTime = setInterval(function () {
            $(".next").eq(nowIndex).click();
        }, 3000);
    });
    function bannerAnimate() {
        $(".bannerSlide .item").removeClass("active");
        $(".bannerSlide .item").eq(nowIndex).addClass("active");
        $(".middle_points span").removeClass("now");
        $(".middle_points span").eq(nowIndex).addClass("now");
    };
    $(".kj_product_inner .next1").click(function () {
        var clone1 = $(".kj_product_inner.active .kj_product_inner1 > ul > li:first-child").clone(true);
        $(".kj_product_inner.active .kj_product_inner1 > ul > li:first-child").fadeOut(200);
        $(".kj_product_inner.active .kj_product_inner1 > ul > li:first-child").remove();
        $(".kj_product_inner.active .kj_product_inner1 > ul").append(clone1);
    });
    $(".kj_product_inner .prev1").click(function () {
        var clone2 = $(".kj_product_inner.active .kj_product_inner1 > ul > li:last-child").clone(true);
        $(".kj_product_inner.active .kj_product_inner1 > ul > li:last-child").fadeOut(200);
        $(".kj_product_inner.active .kj_product_inner1 > ul > li:last-child").remove();
        $(".kj_product_inner.active .kj_product_inner1 > ul").prepend(clone2);
    });
    $(".kj_pinpai_arrow .next1").click(function () {
        var clone3 = $(".kj_pinpai_inner > ul > li:first-child").clone(true);
        $(".kj_pinpai_inner > ul > li:first-child").fadeOut(200);
        $(".kj_pinpai_inner > ul > li:first-child").remove();
        $(".kj_pinpai_inner > ul").append(clone3);
    });
    $(".kj_pinpai_arrow .prev1").click(function () {
        var clone4 = $(".kj_pinpai_inner > ul > li:last-child").clone(true);
        $(".kj_pinpai_inner > ul > li:last-child").fadeOut(200);
        $(".kj_pinpai_inner > ul > li:last-child").remove();
        $(".kj_pinpai_inner > ul").prepend(clone4);
    });
    $(".kj_product_list a").click(function () {
        var nowIndex1 = $(this).index();
        $(this).addClass("active").siblings().removeClass("active");
        $(this).parent().parent().parent().children(".kj_product_inner").removeClass("active").eq(nowIndex1).addClass("active");
    });
    $(".title ul li").click(function () {
        var nowIndex2 = $(this).index();
        $(this).addClass("active").siblings().removeClass("active");
        $(this).parent().parent().parent().children("ul").removeClass("active").eq(nowIndex2).addClass("active");
    });
    $(".kj_productlist_inner > ul li").hover(function () {
        $(this).find(".kj_pi_foot").fadeIn(500);
    }, function () {
        $(this).find(".kj_pi_foot").fadeOut(500);
    });
    $(".return_top").click(function () {
        $("html,body").animate({ scrollTop: 0 }, 500);
    });
    $(".kj_pa_title > li").click(function () {
        $(this).addClass("active").siblings().removeClass("active");
    });
    $(window).scroll(function () {
        if ($(this).scrollTop() > 280) {
            $(".kj_head").css({ "position": "fixed", "top": "0", "z-index": "9999", "border-bottom": "solid 1px #ccc", "box-shadow": "0 1px 5px #ccc" });
        } else {
            $(".kj_head").css({ "position": "static", "border-bottom": "0", "box-shadow": "none" });
        }
    });
});